#include "Power.h"

Power::Power(void)
{
	_timeAnimation=500; //500miliseconds
	isActived=false;
}
Power::Power(int _type)
{
	_typePower=_type;
}
Power::Power(float x, float y, float vx, float vy, int deltaTime,int resourceName,CResourceManager* rm):MovingObject(x,y,vx,vy,deltaTime,resourceName,rm)
{
	isActived=true;
}
Power::Power(int x, int y, int Width, int Height, float vx, float vy, int deltaTime, LPD3DXSPRITE spriteHandler, LPDIRECT3DTEXTURE9 image):MovingObject(x,y,Width,Height,vx,vy,deltaTime,spriteHandler,image)
{
	isActived=true;
}
void Power::SetTimeAnimation(float _time)
{
	_timeAnimation=_time;
	_timeStartAnimation=GetTickCount();
}
void Power::SetTypePower(int _type)
{
	_typePower=_type;
	if(_typePower==1)
	{
		_sprite=_spriteFlower;
	}
	else
	{
		if (_typePower==2)
		{
			_sprite=_spriteMushroom;
		}
		else
		{
			_sprite=_spriteCoin;

		}
	}
}
void Power::SetXY(float _eX,float _eY)
{
	_x=_eX;
	_y=_eY;
}
void Power::SetVX(float vx)
{
	_vx=vx;
}
void Power::SetVY(float vy)
{
	_vy=vy;
}
void Power::Move()
{
	_x+=_vx;
	_y+=_vy;
}
void Power::SetIsActived(bool _isactived)
{
	isActived=_isactived;
}
void Power::Render()
{
	float sx,sy;
	CScreen::getPosition(sx,sy);

	if(_typePower==1 || _typePower==2)
	{
		_sprite->Render(_x-sx,_y-sy);
	}
	else
	{
		float _timeNow=GetTickCount();
		if(_timeNow-_timeStartAnimation<_timeAnimation)
		{
			_sprite->Render(_x-sx,_y);
		}
		else  //if time's out, don't  active this object
		{
			SetIsActived(false);
		}
	}
	
	
}